package common.utils;


import javax.servlet.http.HttpServletRequest;

//import org.apache.log4j.Logger;

/**
 * 
 * Cookie 工具类
 *
 */
public final class SessionUtils {
	



	
	/**
	  * 设置session的值
	  * @param request
	  * @param key
	  * @param value
	  */
	 public static void setAttr(HttpServletRequest request,String key,Object value){
		 request.getSession(true).setAttribute(key, value);
	 }
	 
	 
	 /**
	  * 获取session的值
	  * @param request
	  * @param key
	  * @param value
	  */
	 public static Object getAttr(HttpServletRequest request,String key){
		 return request.getSession(true).getAttribute(key);
	 }
	 
	 /**
	  * 删除Session值
	  * @param request
	  * @param key
	  */
	 public static void removeAttr(HttpServletRequest request,String key){
		 request.getSession(true).removeAttribute(key);
	 }
	 
	 /**
	  * 设置用户信息 到session
	  * @param request
	  * @param user
	  */
	 /*public static void setUser(HttpServletRequest request,SysUser user){
		 request.getSession(true).setAttribute(SESSION_USER, user);
	 }
	 
	 
	 */
	 /**
	  * 从session中获取管理员id
	  * @param request
	  * @return Integer
	  */
	 public static Integer getAdminId(HttpServletRequest request){
		return (Integer)request.getSession(true).getAttribute(Constants.ADMIN_ID);
	 }
	 
	 /**
	  * 从session中获取管理员登录名
	  * @param request
	  * @return Integer
	  */
	 public static String getAdminName(HttpServletRequest request){
		return (String)request.getSession(true).getAttribute(Constants.LOGINNAME);
	 }
	 

}